package main

import (
	"TaskAssignmentSystem/internal/pkg/modelbase"
	datasource "TaskAssignmentSystem/pkg/db/mysql"
	"flag"
	"github.com/golang/glog"
)

var Models = []interface{}{
	new(modelbase.SystemAdmin),
	new(modelbase.SystemUser),
	new(modelbase.SystemUserRestriction),
	new(modelbase.SystemProject),
	new(modelbase.SystemMsg),
	new(modelbase.SystemTopic),
	new(modelbase.TopicNote),
	new(modelbase.TopicConfiguration),
	new(modelbase.HomeNotice),
	new(modelbase.TopicAnswer),
	new(modelbase.TopicUserRecord),
	new(modelbase.UserMessage),
	new(modelbase.SystemTask),
	new(modelbase.SystemDict),
	new(modelbase.SystemProhibitedWords),
	new(modelbase.SystemAdv),
	new(modelbase.SystemAdvLog),
	new(modelbase.SystemProduct),
	new(modelbase.SystemOrder),
	new(modelbase.SystemOrderReviewRecord),
}

// 初始化数据库表
func main() {
	flag.Parse()
	defer glog.Flush()
	glog.Info("====CREATE TABLE START====")
	_db := datasource.GetDB()
	if err := _db.AutoMigrate(Models...); err != nil {
		glog.Errorf("auto migrate tables failed: %s", err.Error())
	}
	glog.Info("====CREATE TABLE END====")
}
